package com.atsmart.app.utils;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkStateUtil {
	private static NetworkStateUtil netStateUtil = null;
	private ConnectivityManager mConnectivityManager;

	public static NetworkStateUtil getInstance() {
		if (netStateUtil == null) {
			netStateUtil = new NetworkStateUtil();
		}

		return netStateUtil;
	}

	private NetworkStateUtil(){
//		Context context = AppContent.getInstance().getApplicationContext();
//		mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	}

	public boolean IsNetworkAvailable(){
		return getNetWorkType() != -1;
	}

	private int getNetWorkType() {
		if (mConnectivityManager != null) {
			NetworkInfo networkInfo = mConnectivityManager
					.getActiveNetworkInfo();
			if (networkInfo != null)
				return networkInfo.getType();
			return -1;
		} else {
			return -1;
		}
	}
}
